home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / text / edit / Smartindent.lha / Smartindent / Source / compiler.h next >
C/C++ Source or Header  |  1997-12-14  |  4KB  |  137 lines

  1. /*
  2. **      $VER: compiler.h 37.10 (1.4.97)
  3. **
  4. **      Compiler independent register (and SAS/C extensions) handling
  5. **
  6. **      (C) Copyright 1997 Andreas R. Kleinert
  7. **      All Rights Reserved.
  8. */
  9.  
  10. /* Basically, Amiga C compilers must reach the goal to be
  11.    as SAS/C compatible as possible. But on the other hand,
  12.    when porting AmigaOS to other platforms, one perhaps
  13.    can't expect GCC becoming fully SAS/C compatible...
  14.  
  15.    There are two ways to make your sources portable:
  16.  
  17.     - using non ANSI SAS/C statements and making these
  18.       "available" to the other compilers (re- or undefining)
  19.     - using replacements for SAS/C statements and smartly
  20.       redefining these for any compiler
  21.  
  22.    The last mentioned is the most elegant, but may require to
  23.    rewrite your source codes, so this compiler include file
  24.    basically does offer both.
  25.  
  26.    For some compilers, this may have been done fromout project or
  27.    makefiles for the first method (e.g. StormC) to ensure compileablity.
  28.  
  29.    Basically, you should include this header file BEFORE any other stuff.
  30. */
  31.  
  32. /* ********************************************************************* */
  33. /* Method 1: redefining SAS/C keywords                                   */
  34. /*                                                                       */
  35. /* Sorry, this method does not work with register definitions for the current
  36. gcc version (V2.7.2.1), as it expects register attributes after the parameter
  37. description. (This is announced to be fixed with gcc V2.8.0).
  38. Moreover the __asm keyword has another meaning with GCC.
  39. Therefore ASM must be used. */
  40.  
  41. #ifdef __MAXON__  // ignore this switches of SAS/Storm
  42. #define __aligned
  43. #define __asm
  44. #define __regargs
  45. #define __saveds
  46. #define __stdargs
  47. #endif
  48.  
  49. #ifdef __GNUC__  // ignore this switches of SAS/Storm
  50. #define __d0
  51. #define __d1
  52. #define __d2
  53. #define __d3
  54. #define __d4
  55. #define __d5
  56. #define __d6
  57. #define __d7
  58. #define __a0
  59. #define __a1
  60. #define __a2
  61. #define __a3
  62. #define __a4
  63. #define __a5
  64. #define __a6
  65. #define __a7
  66. #endif
  67.  
  68.  /* for SAS/C we don't need this, for StormC this is done in the
  69.     makefile or projectfile */
  70.  
  71. /*                                                                       */
  72. /* ********************************************************************* */
  73.  
  74.  
  75. /* ********************************************************************* */
  76. /* Method 2: defining our own keywords                                   */
  77. /*                                                                       */
  78. #ifdef __SASC
  79.  
  80. #  define REG(r)     register __ ## r
  81. #  define GNUCREG(r)
  82. #  define SAVEDS     __saveds
  83. #  define ASM        __asm
  84. #  define REGARGS    __regargs
  85. #  define STDARGS    __stdargs
  86. #  define ALIGNED    __aligned
  87.  
  88. #else
  89. # ifdef __MAXON__
  90.  
  91. #   define REG(r)    register __ ## r
  92. #   define GNUCREG(r)
  93. #   define SAVEDS
  94. #   define ASM
  95. #   define REGARGS
  96. #   define STDARGS
  97. #   define ALIGNED
  98.  
  99. # else
  100. #   ifdef __STORM__
  101.  
  102. #     define REG(r)  register __ ## r
  103. #     define GNUCREG(r)
  104. #     define SAVEDS  __saveds
  105. #     define ASM
  106. #     define REGARGS
  107. #     define STDARGS
  108. #     define ALIGNED
  109.  
  110. #   else
  111. #     ifdef __GNUC__
  112.  
  113. #       define REG(r)  
  114. #       define GNUCREG(r)  __asm( ## r)
  115. #       define SAVEDS  __saveds
  116. #       define ASM
  117. #       define REGARGS __regargs
  118. #       define STDARGS __stdargs
  119. #       define ALIGNED __aligned
  120.  
  121. #     else /* any other compiler, to be added here */
  122.  
  123. #       define REG(r)
  124. #       define GNUCREG(r)
  125. #       define SAVEDS
  126. #       define ASM
  127. #       define REGARGS
  128. #       define STDARGS
  129. #       define ALIGNED
  130.  
  131. #     endif /* __GNUC__ */
  132. #   endif /* __STORM__ */
  133. # endif /* __MAXON__ */
  134. #endif /* __SASC */
  135. /*                                                                       */
  136. /* ********************************************************************* */
  137.